<template>
    <div class="news-container">
        <h1>{{newsinfo.title}} </h1>
        <div class="info">
            <span>发表时间 : {{ newsinfo.add_time | dateFormat}}</span>
            <span>点击 {{ newsinfo.click }}次</span>
        </div>
        <hr>
        <div class="content" v-html="newsinfo.content">
        </div>
        <!-- 评论区 -->
        <comment :artid="id" :type="'article'"></comment>
    </div>
</template>
<script>
import comment from '../subcomponents/Comment.vue'
import { Toast } from "mint-ui"
export default {
        data(){
            return{
                id:this.$route.params.id,
                newsinfo:''
            }
        },
        created(){
            this.getNewsInfo()
        },
        methods:{
            getNewsInfo(){
                this.$http.get("api/getnew/"+this.id).then(response=>{
                    if(response.body.status === 0){
                        this.newsinfo = response.body.message
                        Toast({message:"新闻详情获取ok",duration:500})
                    }else{
                        Toast({message:"新闻详情获取失败",duration:500})
                    }
                })
            }
        },
        components:{
            comment
        }
    }
</script>
<style lang="scss" >
.news-container{
    padding:5px;
    h1{
        font-size:16px;
        color:red;
        text-align:center;
        padding:10px 0;
    }
    .info{
        font-size:13px;
        color:cadetblue;
        display:flex;
        justify-content:space-between;

    }
    .content{
        img{
            width:100%;
        }
    }
}
</style>
